ChansEnhanced_Log("overlay.js, line 1");
var ChansEnhanced = new Object();
ChansEnhanced.UniqueNumber	= 1;
ChansEnhanced.Pages		= [];
ChansEnhanced.ArchiveMark	= String.fromCharCode(8205,8204,8205,8204);
ChansEnhanced.FieldTypes	= {
	"akane"		: "name",
	"nabiki"	: "email",
	"kasumi"	: "subject",
	"gb2"		: "gb2",
	"captcha"	: "captcha",
	"parent"	: "parent",
	"nya2"		: "email",
	"nya3"		: "subject",
	"postredir"	: "postredir",
	"field1"	: "name",
	"email"		: "email",
	"subject"	: "subject",
	"name"		: "name",
	"sub"		: "subject",
	"resto"		: "parent",
	"board"		: "board",
	"replythread"	: "parent",
	"em"		: "email",
	"embed"		: "embed",
	"gotothread"	: "gotothread",
	"jesuslol"	: "subject",
	"paradox"	: "url",
	"nofile"	: "nofile",
	"field2"	: "email",
	"field3"	: "subject",
	"title"		: "subject",
	"field_a"	: "name",
	"field_b"	: "email",
	"markup"	: "markup",
	"threadid"	: "parent"
};
ChansEnhanced.QueryInterface = function(aIID)
{
	if (!aIID.equals(Components.interfaces.nsISupports) &&
		!aIID.equals(Components.interfaces.gmIBrowserWindow) &&
		!aIID.equals(Components.interfaces.nsISupportsWeakReference)
	)
    		throw Components.results.NS_ERROR_NO_INTERFACE;
	return this;
}
ChansEnhanced.Initialize = function (event)
{
	ChansEnhanced_Log("ChansEnhanced_Initialize(event) Start");
	
	this.tabBrowser = document.getElementById("content");
	this.appContent = document.getElementById("appcontent");
	this.contextMenu = document.getElementById("contentAreaContextMenu");
	this.statusImage = document.getElementById("gm-status-image");
	this.statusLabel = document.getElementById("gm-status-label");
	this.statusPopup = document.getElementById("gm-status-popup");
	this.statusEnabledItem = document.getElementById("gm-status-enabled-item");
	this.generalMenuEnabledItem = document.getElementById("gm-general-menu-enabled-item");
	this.toolsMenu = document.getElementById("menu_ToolsPopup");
	this.bundle = document.getElementById("gm-browser-bundle");	
	
	//var container = gBrowser.tabContainer;
	this.tabBrowser.addEventListener("TabOpen" , ChansEnhanced.TabAdded, false);
	this.tabBrowser.addEventListener("TabMove" , ChansEnhanced.TabMoved, false);
	this.tabBrowser.addEventListener("TabClose", ChansEnhanced.TabRemoved, false);
	this.tabBrowser.addEventListener("select"  , ChansEnhanced.TabSelected, false);
	
	this.appContent.addEventListener("DOMContentLoaded", ChansEnhanced.PageLoad, false);
	this.tabBrowser.addProgressListener(ChansEnhanced.ProgressListener,Components.interfaces.nsIWebProgress.NOTIFY_ALL);
	
	ChansEnhanced_Log("ChansEnhanced_Initialize(event) End");
}
ChansEnhanced.UnInitialize = function (event)
{
	ChansEnhanced_Log("ChansEnhanced_UnInitialize(event) Start");

	this.tabBrowser.removeEventListener("TabOpen" , ChansEnhanced_TabAdded, false);
	this.tabBrowser.removeEventListener("TabMove" , ChansEnhanced_TabMoved, false);
	this.tabBrowser.removeEventListener("TabClose", ChansEnhanced_TabRemoved, false);	
	this.tabBrowser.removeEventListener("select"  , ChansEnhanced_TabSelected, false);
	this.appContent.removeEventListener("DOMContentLoaded", ChansEnhanced_PageLoad, false);	
	this.tabBrowser.removeProgressListener(ChansEnhanced_ProgressListener);
	ChansEnhanced_Log("ChansEnhanced_UnInitialize(event) End");
}
ChansEnhanced.ProgressListener =
{
	QueryInterface: function(aIID)
	{
		if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
			aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
			aIID.equals(Components.interfaces.nsISupports)
		)
			return this;
		throw Components.results.NS_NOINTERFACE;
	},
	onStateChange: function(aProgress, aRequest, aFlag, aStatus)
	{
		/*ChansEnhanced_Log("ChansEnhanced_ProgressListener.onStateChange: function()");
		ChansEnhanced_Log("\taProgress.DOMWindow.document.location.href='"+aProgress.DOMWindow.document.location.href+"'");
		ChansEnhanced_Log("\taRequest.printable.DOMDocument="+ChansEnhanced_DumpObject(aRequest.printable.DOMDocument));
		ChansEnhanced_Log("\taFlag = "+aFlag);*/
		//ChansEnhanced_Log("ChansEnhanced_ProgressListener.onStateChange: function(aProgress:"+ChansEnhanced_DumpObject(aProgress)+", aRequest:"+ChansEnhanced_DumpObject(aRequest)+", aFlag:"+aFlag+", aStatus:"+ChansEnhanced_DumpObject(aStatus)+")");
		return 0;
	},
	onLocationChange: function(aProgress, aRequest, aURI)
	{
		ChansEnhanced_Log("ChansEnhanced_ProgressListener.onLocationChange: function()");
		ChansEnhanced_Log("\taURI.spec = "+aURI.spec);
		ChansEnhanced_ToggleSidebar(aURI);
		//ChansEnhanced_Log("ChansEnhanced_ProgressListener.onLocationChange: function(aProgress:"+ChansEnhanced_DumpObject(aProgress)+", aRequest:"+ChansEnhanced_DumpObject(aRequest)+", aURI:"+ChansEnhanced_DumpObject(aURI)+")");
		return 0;
	},
	onProgressChange: function(aProgress,aRequest,aCurSelfProgress,aMaxSelfProgress,aCurTotalProgress,aMaxTotalProgress) 
	{
		/*ChansEnhanced_Log("ChansEnhanced_ProgressListener.onProgressChange: function()");
		ChansEnhanced_Log("\taProgress.DOMWindow.document.location.href='"+aProgress.DOMWindow.document.location.href+"'");
		ChansEnhanced_Log("\taRequest.printable.DOMDocument.location.href="+aRequest.printable.DOMDocument.location.href);
		ChansEnhanced_Log("\t"+aCurSelfProgress+","+aMaxSelfProgress+","+aCurTotalProgress+","+aMaxTotalProgress);*/
		//ChansEnhanced_Log("ChansEnhanced_ProgressListener.onProgressChange: function(aProgress:"+ChansEnhanced_DumpObject(aProgress)+",aRequest:"+ChansEnhanced_DumpObject(aRequest)+","+aCurSelfProgress+","+aMaxSelfProgress+","+aCurTotalProgress+","+aMaxTotalProgress+")");
		return 0;
	},
	onStatusChange: function(aProgress,aRequest,aStatus,aMessage) 
	{
		//ChansEnhanced_Log("ChansEnhanced_ProgressListener.onStatusChange: function(aWebProgress,aRequest,"+aStatus+","+aMessage+")");
		return 0;
	},
	onSecurityChange: function() 
	{
		//ChansEnhanced_Log("ChansEnhanced_ProgressListener.onSecurityChange:");
		return 0;
	},
	onLinkIconAvailable: function(aBrowser) 
	{
		ChansEnhanced_Log("ChansEnhanced_ProgressListener.onLinkIconAvailable: function()");
		//ChansEnhanced_Log("ChansEnhanced_ProgressListener.onLinkIconAvailable: function(aBrowser:"+ChansEnhanced_DumpObject(aBrowser)+")");
		return 0;
	}
}
ChansEnhanced.TabAdded = function (event)
{
	var browser = event.target.linkedBrowser;
	//ChansEnhanced_Log("ChansEnhanced_TabAdded()");
	//ChansEnhanced_Log("\tbrowser.document.location.href="+browser.document.location.href);
	//ChansEnhanced_Log("ChansEnhanced_TabAdded(event:"+ChansEnhanced_DumpObject(event)+")");
}
ChansEnhanced.TabMoved = function (event)
{
	var browser = event.target.linkedBrowser;
	//ChansEnhanced_Log("ChansEnhanced_TabMoved()");
	//ChansEnhanced_Log("\tbrowser.document.location.href="+browser.document.location.href);
	//ChansEnhanced_Log("ChansEnhanced_TabMoved(event:"+ChansEnhanced_DumpObject(event)+")");
}
ChansEnhanced.TabRemoved = function (event)
{
	var browser = event.target.linkedBrowser;
	//ChansEnhanced_Log("ChansEnhanced_TabRemoved()");
	//ChansEnhanced_Log("\tbrowser.document.location.href="+browser.document.location.href);
	//ChansEnhanced_Log("ChansEnhanced_TabRemoved(event:"+ChansEnhanced_DumpObject(event)+")");
}
ChansEnhanced.TabSelected = function (event)
{
	var browser = gBrowser.selectedTab.linkedBrowser;
	//ChansEnhanced_Log("ChansEnhanced_TabSelected()");
	//ChansEnhanced_Log("\tbrowser.document.location.href="+browser.document.location.href);
	//ChansEnhanced_Log("ChansEnhanced_TabSelected(event:"+ChansEnhanced_DumpObject(event)+")");
}
ChansEnhanced.PageLoad = function (event)
{
	var doc = event.originalTarget;
	ChansEnhanced_Log("ChansEnhanced_PageLoad()");
	ChansEnhanced_Log("\tdoc.location.href="+doc.location.href);
	if (ChansEnhanced_IsImageBoard(doc))
	{
		ChansEnhanced_Log("\tIt is imageboard, engage processing algo");
		ChansEnhanced_Process(doc);
	}
}



ChansEnhanced_Log("overlay.js, line 158");
window.addEventListener('load'	, ChansEnhanced.Initialize	, false);
window.addEventListener('unload', ChansEnhanced.UnInitialize	, false);
ChansEnhanced_Log("overlay.js, line 161");